import { Injectable } from '@nestjs/common';
import { JwtService } from '@nestjs/jwt';
import { UserRegisterModel } from '../../user/model/user.dto';

@Injectable()
export class AuthService {
  constructor(private readonly jwtService: JwtService) {}

  async getToken(user: UserRegisterModel) {
    const payload = { username: user.username, password: user.password };
    return {
      access_token: this.jwtService.sign(payload),
    };
  }

  getTokenInfo(token: string) {
    return this.jwtService.verify(token);
  }
}
